home *** CD-ROM | disk | FTP | other *** search
- #include <method\methodSx.h>
- #include <sxlib.h>
- #include "pcm8pp.h"
- #include "spsx.h"
-
- int iPcmPlayMain(tsevent *ts);
- int iPcmPlayInit(tsevent *ts);
- int iPcmPlayEnd(tsevent *ts);
- int iPcmPlayPause(tsevent *ts);
- int iPcmPlayRestart(tsevent *ts);
-
- extern uchar *pcPcmData[2]; /* PCMバッファ */
- extern uchar acFileName[256]; /* 再生ファイル名 */
- extern int iPlayFlag; /* 再生フラグ( 0:再生終了 1:再生中) */
-
- int iFileHandle; /* オープンしたファイルハンドル */
- int iUse;
- int iReadSize; /* PCMバッファに取り込まれている大きさ */
-
- int iPlayFmt; /* 再生フォーマット */
-
- int iByteOf1sec; /* 1秒当たりのByte数 */
- int iPlayByteCount; /* 再生したByte数 */
- int iReadByteCount; /* 読み込んだByte数 */
- int iPlayTime; /* 再生した秒数 */
-
- job_t jobPcmPlay = { NULL,
- iPcmPlayMain,
- iPcmPlayInit,
- iPcmPlayEnd,
- iPcmPlayPause,
- iPcmPlayRestart,
- 0 };
-
- int iPcmPlayMain(tsevent *ts)
- {
- int i;
-
- int iRead=0;
-
- int iRestSize; /* 再生の残りサイズ */
-
- static int iCallPlaySize=0; /* 再生に使ったバッファサイズ */
- static int iFlagOfEOF=0;
-
- iRestSize = iPcm8Stat(0);
-
- if (iRestSize <= iByteOf1sec / 100 ) {
-
- while( iPcm8Stat(0) > 0);
-
- if ( iReadSize == 0 ) {
-
- iFlagOfEOF = 0;
- UnchainAJob(&jobPcmPlay);
- return 0;
- }
- else {
- iPcm8Play( 0,
- iPlayFmt,
- iReadSize,
- pcPcmData[iUse] );
- iUse = iUse ^ 0x01;
- iCallPlaySize = iReadSize;
- iRestSize = iReadSize;
- iReadByteCount += iReadSize;
- iReadSize = 0;
- }
- }
-
- if ( iReadSize < PCM_BUF_SIZE && iFlagOfEOF == 0) {
- iRead = DOSREAD(iFileHandle,pcPcmData[iUse]+iReadSize,FILE_READ_SIZE);
- iReadSize += iRead;
-
- if (iRead == 0 ) {
- iFlagOfEOF = 1;
- }
- }
-
- iPlayByteCount = iReadByteCount - iRestSize;
-
- i = iPlayByteCount / iByteOf1sec;
-
- if ( i != iPlayTime ) {
- iPlayTime = i;
- iDrawPlayTime();
- }
-
- }
-
- int iPcmPlayInit(tsevent *ts)
- {
-
- iFileHandle = TSOpen(acFileName, _O_RDONLY);
-
- if ( iFileHandle <= 0 ) {
- DMError( 1, "ファイルを開けません");
- iPlayFlag = 0;
-
- return -1;
- }
-
- iUse = 0;
- iPlayTime = 0;
- iByteOf1sec = 44100*2*2;
-
- iPlayByteCount = 0;
- iReadByteCount = 0;
-
- iPlayFmt = VOLUME_SIZE_8 | STEREO_16bit_44_1 | OUTPUT_PAN_LR;
-
- iReadSize = DOSREAD(iFileHandle,pcPcmData[iUse],PCM_BUF_SIZE);
- }
-
- int iPcmPlayEnd(tsevent *ts)
- {
- iPlayTime = 0;
- iDrawPlayTime();
-
- iPcm8Stop();
- TSClose(iFileHandle);
-
- iPlayFlag = 0;
-
-
- }
-
- int iPcmPlayPause(tsevent *ts)
- {
- iPcm8Pause();
- }
-
- int iPcmPlayRestart(tsevent *ts)
- {
- iPcm8Restart();
- }